home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 2 / Amiga Tools 2.iso / tools / jade / src / edit.h < prev    next >
C/C++ Source or Header  |  1995-03-09  |  6KB  |  209 lines

  1. /* edit.h -- Data structures for the editor (buffers, marks, etc...)
  2.    Copyright (C) 1993, 1994 John Harper <jsh@ukc.ac.uk>
  3.  
  4.    This file is part of Jade.
  5.  
  6.    Jade is free software; you can redistribute it and/or modify it
  7.    under the terms of the GNU General Public License as published by
  8.    the Free Software Foundation; either version 2, or (at your option)
  9.    any later version.
  10.  
  11.    Jade is distributed in the hope that it will be useful, but
  12.    WITHOUT ANY WARRANTY; without even the implied warranty of
  13.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.    GNU General Public License for more details.
  15.  
  16.    You should have received a copy of the GNU General Public License
  17.    along with Jade; see the file COPYING.    If not, write to
  18.    the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #ifndef _EDIT_H
  21. #define _EDIT_H
  22.  
  23. /*
  24.  * Line structure -- an array of these is in the TX->tx_Lines
  25.  */
  26. typedef struct LINE {
  27.     u_char       *ln_Line;
  28.     long        ln_Strlen;    /* includes '\0' */
  29. } LINE;
  30.  
  31. /*
  32.  * Structure to uniquely identify a character position
  33.  */
  34. typedef struct POS {
  35.     long        pos_Col, pos_Line;
  36. } POS;
  37.  
  38. #define POS_EQUAL_P(s,e) \
  39.     (((s)->pos_Line == (e)->pos_Line) && ((s)->pos_Col == (e)->pos_Col))
  40. #define POS_GREATER_P(s,e) \
  41.     (((s)->pos_Line > (e)->pos_Line) \
  42.      || (((s)->pos_Line == (e)->pos_Line) && ((s)->pos_Col > (e)->pos_Col)))
  43. #define POS_GREATER_EQUAL_P(s,e) \
  44.     (((s)->pos_Line > (e)->pos_Line) \
  45.      || (((s)->pos_Line == (e)->pos_Line) && ((s)->pos_Col >= (e)->pos_Col)))
  46. #define POS_LESS_P(s,e) \
  47.     (((s)->pos_Line < (e)->pos_Line) \
  48.      || (((s)->pos_Line == (e)->pos_Line) && ((s)->pos_Col < (e)->pos_Col)))
  49. #define POS_LESS_EQUAL_P(s,e) \
  50.     (((s)->pos_Line < (e)->pos_Line) \
  51.      || (((s)->pos_Line == (e)->pos_Line) && ((s)->pos_Col <= (e)->pos_Col)))
  52.  
  53. /*
  54.  * Each bookmark has one of these in the tx_Marks list
  55.  */
  56. typedef struct _Mark {
  57.     u_char        mk_Type;
  58.     bool        mk_Resident;
  59.  
  60.     /* When the file is resident this node is linked into its tx_Marks list,
  61.        otherwise it's in a list of all non-resident marks.  */
  62.     struct _Mark   *mk_Next;
  63.  
  64.     /* next allocated MARK  */
  65.     struct _Mark   *mk_NextAlloc;
  66.  
  67.     VALUE        mk_Pos;
  68.  
  69.     /* This union tells me where to look for the file this mark is in.
  70.        if (mk_Resident == 0) then the file (mk_File.name) has to be loaded and
  71.        used. Otherwise (mk_File.tx) is used.  */
  72.     union {
  73.     VALUE        name;
  74.     /* this TX should not be marked for gc */
  75.     struct _TX     *tx;
  76.     }            mk_File;
  77. } Mark;
  78.  
  79. /*
  80.  * A buffer, strangely called `TX'
  81.  */
  82. typedef struct _TX {
  83.     u_char        tx_Type;
  84.     u_char        tx_Flags;
  85.     u_char        tx_Pad1, tx_Pad2;
  86.  
  87.     struct _TX       *tx_Next;
  88.     Mark       *tx_MarkChain;
  89.     LINE       *tx_Lines;
  90.     long        tx_NumLines;
  91.     VALUE        tx_FileName;
  92.     VALUE        tx_BufferName;
  93.     VALUE        tx_ModeName;
  94.     VALUE        tx_MinorModeNameList;
  95.     VALUE        tx_MinorModeNameString;
  96.     long        tx_Changes;
  97.     long        tx_AutoSaveInterval; /* seconds between saves */
  98.     long        tx_LastSaveTime;     /* time at last save (auto or user) */
  99.     long        tx_LastSaveChanges;     /* changes at last save (any type) */
  100.     long        tx_ProperSaveChanges; /* changes at last `proper' save */
  101.  
  102.     long        tx_TabSize;
  103.  
  104.     /* Section of buffer which may have changed since last refresh.  */
  105.     POS            tx_ModStart, tx_ModEnd;
  106.     /* How many more lines in the above area than at the last refresh.    */
  107.     long        tx_ModDelta;
  108.     /* `tx_Changes' at last refresh.  */
  109.     long        tx_LastChanges;
  110.  
  111.     VALUE        tx_LocalVariables; /* alist of (SYMBOL . VALUE) */
  112.     VALUE        tx_GlyphTable;
  113.  
  114.     /* Undo information */
  115.     VALUE        tx_UndoList;
  116.     VALUE        tx_ToUndoList;
  117.     VALUE        tx_UndoneList;
  118.  
  119.     /* Saved state for buffers which are not being displayed.  */
  120.     POS            tx_SavedCPos;
  121.     POS            tx_SavedWPos;
  122.     POS            tx_SavedBlockPos[2];
  123.     char        tx_SavedBlockStatus;
  124. } TX;
  125.  
  126. /* For tx_Flags */
  127. #define TXFF_RDONLY   1        /* No modifications to file */
  128. #define TXFF_SPECIAL  2        /* No mod flag, buffer never killed. */
  129. #define TXFF_REFRESH_ALL 4  /* *All* buffer has changed. */
  130. #define TXFF_NO_UNDO  8        /* No recording of undo information */
  131.  
  132. /*
  133.  * Each window is like this
  134.  */
  135. typedef struct _VW
  136. {
  137.     u_char        vw_Type;
  138.     u_char        vw_Flags;
  139.     u_char        vw_Pad1, vw_Pad2;
  140.  
  141.     struct _VW       *vw_Next;
  142.     TX           *vw_Tx;
  143.  
  144.     /* Data that the window-system needs.  */
  145.     VW_WindowSys    vw_WindowSys;
  146.  
  147.     /* Cursor positioning data.  */
  148.     POS            vw_CursorPos;
  149.     u_long        vw_LastCursorOffset; /* number of glyphs from col 0 */
  150.     POS            vw_LastCursorPos;
  151.     u_long        vw_LastCursorChanges;
  152.     TX           *vw_LastCursorTx;
  153.  
  154.     POS            vw_DisplayOrigin;
  155. #define vw_StartLine vw_DisplayOrigin.pos_Line
  156. #define vw_StartCol vw_DisplayOrigin.pos_Col
  157.  
  158.     POS            vw_BlockS, vw_BlockE;
  159.     /* 0=block marked, 1=start marked, 2=end marked, -1=none marked */
  160.     char        vw_BlockStatus;
  161.  
  162.     u_char       *vw_Message;
  163.     u_long        vw_MessageLen;
  164.     u_long        vw_LastClickMics;
  165.  
  166.     int            vw_MaxX, vw_MaxY;
  167.     int            vw_XStartPix, vw_YStartPix;
  168.     int            vw_XEndPix, vw_YEndPix;
  169.     int            vw_XWidthPix, vw_YHeightPix;
  170.     short        vw_XStep, vw_YStep;
  171.     short        vw_XStepRatio, vw_YStepRatio;
  172.  
  173.     /* Position at which to draw the separator line and the base-line
  174.        for the message text.  */
  175.     int            vw_MessageLineY;
  176.     int            vw_MessageFontY;
  177.  
  178.     VALUE        vw_FontName;
  179.     short        vw_FontStart;
  180.     short        vw_FontX, vw_FontY;
  181.  
  182.     TX           *vw_LastRefTx;
  183.     POS            vw_LastDisplayOrigin;
  184.     short        vw_DeferRefresh;
  185.     u_short        vw_MaxScroll;
  186.  
  187. #ifndef NOSCRLBAR
  188.     ScrollBar        vw_SBar;
  189. #endif
  190.  
  191.     /* List of buffers accessible in this window.  This is not used by the
  192.        C code at all; access is via the `buffer-list' variable.  */
  193.     VALUE        vw_BufferList;
  194. } VW;
  195.  
  196. /* For vw_Flags     */
  197. #define VWFF_RECTBLOCKS     1    /* mark rectangular blocks */
  198. #define VWFF_FORCE_REFRESH  2    /* full redraw next time */
  199. #define VWFF_REFRESH_BLOCK  4    /* redraw the block */
  200. #define VWFF_REFRESH_STATUS 8    /* redraw the status line */
  201. #define VWFF_SLEEPING        16    /* window is iconified */
  202. #define VWFF_MESSAGE        32    /* a message is currently displayed */
  203. #define VWFF_STATUS_CURS    64    /* cursor is draw at end of status msg */
  204.  
  205. #define CURS_ON     1
  206. #define CURS_OFF 0
  207.  
  208. #endif /* _EDIT_H */
  209.